Table 17-4 illustrates how a .NET base class type maps to the corresponding C# keyword, and how each C# keyword maps into raw CIL. As well, Table 17-4 documents the shorthand constant notations used for each CIL type. As you will see in just a moment, these constants are often referenced by numerous CIL opcodes.
Table 17-4. Mapping .NET Base Class Types to C# Keywords, and C# Keywords to CIL
.NET Base Class Type | C# Keyword | CIL Representation | CIL Constant Notation |
---|---|---|---|
System.SByte | sbyte | int8 | I1 |
System.Byte | byte | unsigned int8 | U1 |
System.Int16 | short | int16 | I2 |
System.UInt16 | ushort | unsigned int16 | U2 |
System.Int32 | int | int32 | I4 |
System.UInt32 | uint | unsigned int32 | U4 |
System.Int64 | long | int64 | I8 |
System.UInt64 | ulong | unsigned int64 | U8 |
System.Char | char | char | CHAR |
System.Single | float | float32 | R4 |
System.Double | double | float64 | R8 |
System.Boolean | bool | bool | BOOLEAN |
System.String | string | string | N/A |
System.Object | object | object | N/A |
System.Void | void | void | VOID |
Note The System.IntPtr and System.UIntPtr types map to native int and native unsigned int (this is good to know, as many of COM interoperability and P/Invoke scenarios use these extensively).